TARGET_ARCH = linux

SRCS = vcd2tab.cpp
OBJS = $(addsuffix .o, $(basename $(SRCS)))
DEPS = $(addsuffix .d, $(basename $(SRCS)))
CXX = g++
CXXFLAGS = -Dunix -Wall -Wno-long-long -O3 
TARGETS = vcd2tab
LIBS = -lm -lpthread

# targets

all: $(TARGETS)

clean:
	rm -f $(TARGETS) $(OBJS) $(DEPS)


# rules

include $(DEPS)

vcd2tab: $(OBJS)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)

%.o: %.cpp
	g++ $(CXXFLAGS) -c -o $@ $<

%.o: %.c
	gcc $(CXXFLAGS) -c -o $@ $<

%.d: %.cpp
	g++ -MM -MT $(addsuffix .o, $(basename $@)) $(CXXFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@

%.d: %.c
	gcc -MM -MT $(addsuffix .o, $(basename $@)) $(CXXFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@

.PHONY: all clean
